#pragma once
#include <iostream>

std::string opers="+-*/%";

enum{
    DivZero = 1,
    ModZero,
    Unknown
};

class Task
{
public:
    Task(int a, int b, char op)
        :_data1(a), _data2(b), _ope(op), _ret(0), _exitcode(0)
    {}
    void run()
    {
        switch (_ope)
        {
        case '+':
            _ret = _data1 + _data2;
            break;
        case '-':
            _ret = _data1 - _data2;
            break;
        case '*':
            _ret = _data1 * _data2;
            break;
        case '/':
            {
                if(_data2 == 0) _exitcode = DivZero;
                else _ret = _data1 / _data2;
            } 
            break;
        case '%':
           {
                if(_data2 == 0) _exitcode = ModZero;
                else _ret = _data1 % _data2;        
            } 
            break;
        default:
            _exitcode = Unknown;
            break;
        }
    }

    std::string GetResult()
    {
        return std::to_string(_data1) + " " +
            _ope + " " + std::to_string(_data2) + " " +
            " = " + std::to_string(_ret) +
            + " [eixtcode: " + std::to_string(_exitcode) + "]";
    }

    std::string GetTask()
    {
        return std::to_string(_data1) + " " + _ope + " " + std::to_string(_data2) + " = ? ";
    }

    void operator()()
    {
        run();
    }
private:
    int _data1;
    int _data2;
    char _ope;
    int _ret;
    int _exitcode;

}; 